package status

import (
	"time"
)

var maxAliveTime = time.Second * 30

type VolumeStatus struct {
	Vid             uint64 // 存储块编号 雪花id
	MaxDiskUsed     uint64 // 服务器最大可使用空间
	Writable        bool   // 存储块是否可写入
	VolumeSize      uint64 // volume块占用空间
	VolumeFreeSpace uint64 // volume剩余空间
	StorageStatus   *StorageStatus
}

func NewVolumeStatus(vid uint64, maxDiskUsed uint64, writable bool, volumeSize uint64, volumeFreeSpace uint64) *VolumeStatus {
	return &VolumeStatus{Vid: vid, MaxDiskUsed: maxDiskUsed, Writable: writable, VolumeSize: volumeSize, VolumeFreeSpace: volumeFreeSpace}
}

func (vs *VolumeStatus) IsWriteable(size uint64) bool {
	return vs.Writable && vs.VolumeFreeSpace > size
}
